package com.huang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class LoginController {
    @RequestMapping("/main")
    public String main(){
        return "main";
    }
    @RequestMapping("/gologin")
    public String gologin(){
        return "login";
    }
    @RequestMapping("/login")
    public String login(String username, String pwd, HttpSession session,Model model){
        session.setAttribute("user",username);
        model.addAttribute("user",username);
        return "main";
    }
    @RequestMapping("/goout")
    public String goout(HttpSession session){
        session.removeAttribute("user");
        return "login";
    }
}
